using Avanzis.QueryFramework;
using NUnit.Framework;

namespace Avanzis.QueryBuilder.NUnit
{
	/// <summary>
	/// Order clause
	/// </summary>
	[TestFixture]
	public class GroupByClauseTest
	{
        [TestFixtureSetUp]
        public void Setup()
        {
            QueryFrameworkConfiguration.Dialect = Dialects.MSSql2005Dialect;
            QueryBuilder.QueryProcessor.ResetProcessor();
        }
		
		[Test]
		public void EmptyGroupBy()
		{
			GroupByClause groupBy = new GroupByClause();
			Assert.AreEqual("", groupBy.ToString());
		}

		[Test]
		public void SimpleGroupBy()
		{
			GroupByClause groupBy = new GroupByClause("Articles.Name");
			Assert.AreEqual("GROUP BY Articles.Name", groupBy.ToString());

			groupBy = new GroupByClause();
			groupBy.Fields.Add("Articles.Name");
			Assert.AreEqual("GROUP BY Articles.Name", groupBy.ToString());
		}

		[Test]
		public void MultipleGroupBy()
		{
			GroupByClause groupBy = new GroupByClause("Articles.Name, Articles.Date");
			Assert.AreEqual("GROUP BY Articles.Name, Articles.Date", groupBy.ToString());
			
			groupBy = new GroupByClause();
			groupBy.Fields.Add("Articles.Name");
			groupBy.Fields.Add("Articles.Date");
			Assert.AreEqual("GROUP BY Articles.Name, Articles.Date", groupBy.ToString());
		}
	}
}
